<template>
  <el-drawer @close="closeForm('')" size="500px" :title="mode==='add'?'添加角色组':'编辑角色组'" :visible.sync="visible" :wrapperClosable="false">
    <el-form :model="form" :rules="rules" label-width="100px" class="drawerForm" ref="drawerForm">
      <el-form-item label="角色组名称:" prop="roleName">
        <el-input
            v-model="form.roleName"
            placeholder="请输入"
        ></el-input>
      </el-form-item>
    </el-form>
    <div class="drawer-footer">
      <el-button @click="handleSubmit" :loading="btnLoading" size="small" class="btn plain-btn">保存</el-button>
      <el-button @click="closeForm('')" size="small" class="btn default-btn">取消</el-button>
    </div>
  </el-drawer>
</template>

<script>
import {sandbox} from '@/libs/util'
import drawer from '@/mixins/drawer.js'
export default {
  mixins: [drawer],
  props:{
    visible: {
      type: Boolean,
      default: false,
    },
    mode: {
      type: String,
      default: '',
    },
    selectRow: {
      type: Object,
      default: ()=>{},
    },
  },
  data() {
    return {
      btnLoading:false,
      form: sandbox({
        roleName: '',
        roleStatus: 1,
        roleType: '角色组',
      }),
      rules: {
        roleName: [{required: true, message: '必填项', trigger: 'blur'}],
      },
      treeData:[]
    }
  },
  methods: {
    SetData(row){
      this.$api.api_urcap_departmentManage_listDeptUser({
        param: {
          deptId: this.selectRow.id,
          userName: row.userName
        },
      }).then(res => {
        Object.assign(this.form, res.data[0])
      })
    },
    AddRow(){
      let form = sandbox(this.form)
      return this.$api.api_urcap_roleManage_addRoleGroup({
        body: form,
        config: {showMsg: true}
      })
    },
    UpdateRow(){
      return this.AddRow()
    },

  },

}
</script>

<style scoped lang="scss">

</style>
